package Test;

import org.hibernate.Session;

import entity.User;
import util.HibernateUtil;

public class Test2 {
	public static void main(String args[]){
		Session session = HibernateUtil.getSessionFactory().getCurrentSession();
		User u = new User();
		u.setName("ttt");
		u.setAge(33);
		try{
		session.beginTransaction();
		session.save(u);
		session.getTransaction().commit();
		}catch(Exception ex){
			session.getTransaction().rollback();
			ex.printStackTrace();
		}
		HibernateUtil.getSessionFactory().close();
	}
}
